<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<div id="cc_products" class="easyui-layout" style="width:100%;height:100%;" fit="true">
	<div data-options="region:'north',title:'',split:true" style="height:40px;background-color:#e6edfd;">
    	<form action="" id="searchForm" name="searchForm">
    	<table class="screen">
			<tr>
				<td class="screen-n"><span>商品</span></td>
				<td class="screen-n">
					<input type="text" id="search_productName" class="screen-input" onkeydown="pms.kd13('initProducts')">
				</td>
				<td class="screen-n"><span>品牌</span></td>
				<td class="screen-n">
					<input type="text" id="s_brand" class="screen-input"  onkeydown="pms.kd13('initProducts')">
				</td>
				<td class="screen-n"><span>厂家</span></td>
				<td class="screen-n">
					<input type="text" id="s_producingName" class="screen-input"  onkeydown="pms.kd13('initProducts')">
				</td>
				<td class="screen-n">
					<input type="button" class="button" value="查询" onclick="initProducts()">
					<input type="button" class="button" value="重置" onclick="pms.resetForm('searchForm')" >
				</td>
			</tr>
		</table>
		</form>
    </div>
    <div data-options="region:'center',split:true" style="width: 100%;height: 100%">
		<table id="productGrid"></table>
	</div>
</div>  
<script>
var toolbar = [{
	text:'选择',
    iconCls:'ext-icon-note_add',
    handler:function(){
    	var rows = productsTable.getCheckedData();
		if(rows==null || rows.length==0){
			alertWarning("请选中要添加的商品!");
			return;
		}
		//采购商审核
		if(confirm("确定批量添加?")){
			var productCodes = [];
			for(var i=0; i<rows.length; i++){
				productCodes.push(rows[i].productCode);
			}
			var productCodeList = productCodes.toString();
			parent.getProduct(productCodeList);
		}
    }
}];
var productsTable;
$(function(){
	initProducts();
});

function initProducts(){
	productsTable = $('#productGrid').pDataGrid({
		toolbar:toolbar,
		columns:[[
	          	  {field:'ck',checkbox:true},
	              {field:'productCode',title:'商品编号',align:'center'},
	              {field:'productName',title:'商品名称',align:'center'},
	              {field:'spell',title:'拼音码',align:'center'},
	              {field:'productSpec',title:'规格',align:'center'},
	              {field:'packingUnit',title:'包装',align:'center'},
	              {field:'salePrice',title:'价格',align:'center'},
	              {field:'producingName',title:'生产厂家',align:'center'},
	              {field:'authorizeNumber',title:'批准文号',align:'center'},
	              {field:'brand',title:'品牌',align:'center'},
	              {field:'stockQuantity',title:'库存',align:'center'}
	          ]],
	    url:'<c:url value="/product/searchPageProduct.do"/>',  
	    pagination:true,//分页控件
	    pageSize:30,
	    singleSelect:false,
	    rownumbers:true,
	    queryParams:{
			"productName":$('#search_productName').val(),
			"brand":$("#s_brand").val(),
			"providerCode":"<%=request.getParameter("providerCode")%>",
			"producingName":$("#s_producingName").val()
	    },
		onDblClickRow:function(index,row){
			parent.getProduct(row.productCode);
		}
	}); 
}

 
</script>
